/**
 * 登录用Action
 */
package teatime.core.web.action;

import teatime.core.bussiness.NormalLogin;
import teatime.core.bussiness.base.BaseLogin;
import teatime.core.model.entity.Account;
import teatime.core.service.manager.AccountManager;
import teatime.core.web.action.base.BaseAction;

/**
 * @author ShenJie
 * @since 2008-04-16
 */
@SuppressWarnings("serial")
public class LoginAction extends BaseAction {

	private AccountManager<Account> accountManager;
	
	private Account account;
	
	private String accountName;
	
	private String accountPassword;

	public String getAccountPassword() {
		return accountPassword;
	}

	public void setAccountPassword(String accountPassword) {
		this.accountPassword = accountPassword;
	}

	/**
	 * 
	 */
	public String execute() throws Exception {
		try {
//			BaseLogin login = new NormalLogin(accountName, accountPassword);
			account = accountManager.findUniqueBy(account.PROP_ACCOUNT_NAME, accountName);
			if (account != null && account.getAccountPassword().equals(accountPassword)) {
				setResponse("passed");
			}
		} catch (Exception ex) {
			setResponse(ERROR);
		}
		return null;
	}

	public String getAccountName() {
		return accountName;
	}

	public void setAccountName(String accountName) {
		this.accountName = accountName;
	}

	public void setAccountManager(AccountManager accountManager) {
		this.accountManager = accountManager;
	}
}
